package vip.george.p1523;




public class P1523 {


    /**
     * 奇数个数
     * 暴力思考：枚举边界可能的奇偶情况，然后找规律
     * 1.[偶, 偶]: [2, 4] -> 答案: (4-2)/2
     * 2.[奇, 奇]: [3, 7] -> 答案: (7-3)/2+1
     * 3.[偶, 奇]: [2, 5] -> 答案: (5-2)/2+1
     * 4.[奇, 偶]: [1, 4] -> 答案: (4-1)/2+1
     * @param low
     * @param high
     * @return
     */
    public int countOdds(int low, int high) {
        if (low % 2 == 0 && high % 2 == 0) {
            return (high - low) / 2;
        } else {
            return (high - low) / 2 + 1;
        }
    }


    public static void main(String[] args) {
        P1523 p = new P1523();
        System.out.println(p.countOdds(1, 6));
        System.out.println(p.countOdds(3, 7));
        System.out.println(p.countOdds(0, 1));
        System.out.println(p.countOdds(8, 10));
    }
}
